package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TcommentDao;
import com.xy.manage.model.Tcomment;
import com.xy.manage.service.TcommentService;

@Service
@Transactional
public class TcommentServiceImpl extends BaseServiceImpl<Tcomment> implements
		TcommentService {
	private TcommentDao tcommentDao;

	public TcommentServiceImpl(TcommentDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tcommentDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tcommentDao.checkExist("Tcomment", paraName, paraValue);
	}

	@Override
	public List<Tcomment> getTcomment(Map<String, Object> map) {
		return tcommentDao.getTcomment(map);
	}
	@Override
	public Pagination getTcommentByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tcommentDao.getTcommentByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tcomment save(Tcomment tcomment) {
	//	tcomment.setModtime(new Date());
		if(tcomment.getPid()==null){
			//新增
        	return super.save(tcomment);
		}else{
			//更新
			Tcomment tcomment1=tcommentDao.get(tcomment.getPid());
			try {
				BeanUtil.copyNotNullProperties(tcomment1, tcomment);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tcomment1);
		}
	}
}